package top.gytf.distools.springboot;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Conditional;

import java.lang.annotation.*;

/**
 * 当配置文件满足时（基于配置属性类）
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD })
@Documented
@Conditional(OnPropertyCondition.class)
public @interface ConditionalOnProperty {
    /**
     * 标记了{@link ConfigurationProperties}的配置属性类
     */
    Class<?> properties();

	/**
	 * 配置属性类字段的前缀之后的前缀
	 */
	String[] prefix() default "";

	/**
     * 需要的配置项在配置属性类中的字段名称
     */
    String[] name();

	/**
	 * The string representation of the expected value for the properties. If not
	 * specified, the property must <strong>not</strong> be equal to {@code false}.
	 * @return the expected value
     * @see org.springframework.boot.autoconfigure.condition.ConditionalOnProperty#havingValue()
	 */
	String havingValue() default "";

	/**
	 * Specify if the condition should match if the property is not set. Defaults to
	 * {@code false}.
	 * @return if the condition should match if the property is missing
     * @see org.springframework.boot.autoconfigure.condition.ConditionalOnProperty#matchIfMissing()
	 */
	boolean matchIfMissing() default false;
}
